<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p>count = {{count}}</p>
        <!-- $event:获取当前的 -->
        <div><button @click="add(n,$event)">+1</button></div>
    </div>
    <script src="./lib/vue.js"></script>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                count: 0,
            },
            methods: {
                add(n, e) {
                    this.count += 1;
                    if (this.count % 2 === 0) {
                        // n.target.style.backgroundColor = 'red'
                        e.target.style.backgroundColor = 'red'
                    } else {
                        // n.target.style.backgroundColor = null
                        e.target.style.backgroundColor = null
                    }
                }
            }
        })
    </script>
</body>

</html>